package com.zw.pdm.module.invention.controller;

import com.zw.pdm.base.BaseController;
import com.zw.pdm.common.JsonResult;
import com.zw.pdm.entity.invention.PttInvent;
import com.zw.pdm.module.invention.service.InventionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

import static com.zw.pdm.constant.Constant.GROUP_SPECTYPE;

/**
 * @Description: 计划查询接口
 * @Author: China.sgl
 * @Date: 2020/8/3 16:11
 */
@Controller
@RequestMapping("/invention")
@SuppressWarnings("all")
public class InventionController extends BaseController {


    @Autowired
    private InventionService inventionService;


    @GetMapping
//    @RequiresPermissions({"tec:employee:view"})
    public String page(Model model) {
        return "invention/Page";
    }

    /**
     * 列表查询
     */
    @ResponseBody
    @PostMapping("/query")
//    @RequiresPermissions({"report:query:view"})
    public JsonResult list(PttInvent pttInvent) {
        startPage();
        return jsonResult(inventionService.selectQuery(pttInvent));
    }
    /**
     * 保存列表
     */
    @ResponseBody
    @PostMapping("/save")
    public JsonResult save(PttInvent pttInvent) {
        return jsonResult(inventionService.savePttInvent(pttInvent));
    }
    /**
     * 保存列表
     */
    @ResponseBody
    @PostMapping("/edit")
    public JsonResult edit(PttInvent pttInvent) {
        return jsonResult(inventionService.editPttInvent(pttInvent));
    }
    /**
     * 删除
     */
    @ResponseBody
    @PostMapping("/del")
    public JsonResult del(PttInvent pttInvent) {
        return jsonResult(inventionService.del(pttInvent));
    }
    /**
     * 上传附件保存
     */
    @ResponseBody
    @PostMapping("/upload")
    public JsonResult upload(PttInvent pttInvent,@RequestParam("file") MultipartFile file) {
        return jsonResult(inventionService.upload(pttInvent,file));
    }
}
